package com.lwx.sort;

public class SelectSort {
  public static void main(String[] args) {
    int[] a = new int[] {5, 90, 3, 0, 1, 2, 7, 32, 22, 45};
    sort2(a);
    print(a);
  }
  
  public static void sort1(int[] a){
    for(int i = 0; i < a.length; i++){
      int min = i;
      for(int j = i + 1; j < a.length; j++){
        if(a[j] < a[min]){
          min = j;
        }
      }
      int t = a[i];
      a[i] = a[min];
      a[min] = t;
    }
  }
  
  public static void sort2(int[] a){
    for(int i = 0; i < a.length; i++){
      for(int j = i + 1; j < a.length; j++){
        if(a[i] > a[j]){
          int t = a[i];
          a[i] = a[j];
          a[j] = t;
        }
      }

    }
  }
  
  static void print(int[] a) {
    for (int i = 0; i < 10; i++) {
      System.out.print(a[i] + ",");
    }
    System.out.println();
  }
}
